<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:useBean id="clsConn" class="utility.connections" scope="session"></jsp:useBean>
<%! 
	String codice="",denominazione="", posizione="", note="",user="",qry=""; 
	ResultSet rs;
	String modify;
%>
<%
	if (session.getAttribute("user")==null)
		response.sendRedirect("loginerr.jsp");
	
	modify=request.getParameter("modify").toString();
	if (modify.equalsIgnoreCase("1"))
	{
		codice=request.getParameter("codice");
		denominazione=request.getParameter("denominazione");
		posizione=request.getParameter("posizione");
		note=request.getParameter("note");
		
		qry = "update stanza set denominazione='" + denominazione + "',posizione='" + posizione + "',note='" + note +"' where codice = "+ codice;
		utility.connections.getStatement().executeUpdate(qry);
		
	}
	user = session.getAttribute("user").toString().toLowerCase();
	codice=request.getParameter("codice").toString().toLowerCase();
	
	qry = "select * from stanza where codice = "+codice;
	rs = utility.connections.getStatement().executeQuery(qry);
	
	if (rs.next())
	{
		denominazione=rs.getString("denominazione");
		posizione=rs.getString("posizione");
		note=rs.getString("note");
	}
	else
	{
		codice="";
		denominazione="";
		posizione="";
		note="";
	}
	rs.close();
%>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Calibri, Cambria}
.style3 {font-family: Verdana, Calibri, Cambria; font-size: small; }
.style4 {
	font-family: Verdana, Calibri, Cambria;
	font-weight: bold;
	font-style: italic;
	color: #FFFFFF;
}
-->
</style>
</head>

<body>
<table width="700" height="422" border="0" align="center">
  <tr>
    <td align="center" valign="middle"><img src="images/title.png" width="700" height="100"></td>
  </tr>
  <tr>
    <td height="257" align="center" valign="top"><table width="100%" border="0">
      <tr>
        <td align="center"><div align="left">
          <p class="style3">
          <%out.println("Benvenuto " + user);%>
		  </p>
        </div></td>
        </tr>
      <tr>
        <td class="style1"><p align="center"><strong>Modifica i dati </strong></p></td>
      </tr>
      <tr>
        <td class="style1"><div align="center">
          <form action = "modifica_stanza.jsp?modify=1" method="post">
          <table width="100%" border="0">
            <tr>
              <td width="16%">&nbsp;</td>
              <td width="27%"><div align="right">codice:</div></td>
              <td width="32%"><input type="text" name="codice" size="60" value="<%=codice%>" readonly="readonly" ></input></td>
              <td width="25%">&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><div align="right">denominazione :</div></td>
              <td><input type="text" name="denominazione" size="60" value="<%=denominazione%>" ></input></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><div align="right">posizione:</div></td>
              <td><input type="text" name="posizione" size="60" value="<%=posizione%>"></input></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><div align="right">note:</div></td>
              <td><input type="text" name="note" size="60" value="<%=note%>"></input></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><div align="right"></div></td>
              <td><div align="right">
                <input type="submit" name="btnmodifica" value="MODIFICA" />
            </div></td>
              </tr>
          </table>
          </form>
</div></td>
        </tr>
      <tr>
        <td class="style1"><div align="center">
          <input type="submit" name="btnelimina" value="ELIMINA"  onClick="location.href='elimina_stan.jsp?matricola=<%=codice%>'"/>
          <input type="submit" name="btnreturn" value="INDIETRO"  onClick="location.href='gestione_stanza.jsp?order=4'"/>
        </div></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td align="center" valign="middle">
	<%
		if(modify.equalsIgnoreCase("1"))
			out.println("RECORD MODIFICATO");
	%>
	</td>
  </tr>
  <tr>
    <td align="center" valign="middle" bgcolor="#000099"><div align="right" class="style4">MODIFICA STANZA </div></td>
  </tr>
</table>
</body>
</html>
